/*! ******************************************************************************
 *
 * Pentaho
 *
 * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
 *
 * Use of this software is governed by the Business Source License included
 * in the LICENSE.TXT file.
 *
 * Change Date: 2029-07-20
 ******************************************************************************/


package org.pentaho.runtime.test.result.org.pentaho.runtime.test.result.impl;

import org.pentaho.runtime.test.result.RuntimeTestResultEntry;
import org.pentaho.runtime.test.result.RuntimeTestResultSummary;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by bryan on 8/26/15.
 */
public class RuntimeTestResultSummaryImpl implements RuntimeTestResultSummary {
  private final RuntimeTestResultEntry rollupTestResultEntry;
  private final List<RuntimeTestResultEntry> runtimeTestResultEntries;

  public RuntimeTestResultSummaryImpl() {
    this( null );
  }

  @SuppressWarnings( "unchecked" )
  public RuntimeTestResultSummaryImpl( RuntimeTestResultEntry rollupTestResultEntry ) {
    this( rollupTestResultEntry, Collections.EMPTY_LIST );
  }

  public RuntimeTestResultSummaryImpl( RuntimeTestResultEntry rollupTestResultEntry,
                                       List<RuntimeTestResultEntry> runtimeTestResultEntries ) {
    this.rollupTestResultEntry = rollupTestResultEntry;
    this.runtimeTestResultEntries = Collections.unmodifiableList( new ArrayList<>( runtimeTestResultEntries ) );
  }

  @Override public RuntimeTestResultEntry getOverallStatusEntry() {
    return rollupTestResultEntry;
  }

  @Override public List<RuntimeTestResultEntry> getRuntimeTestResultEntries() {
    return runtimeTestResultEntries;
  }

  //OperatorWrap isn't helpful for autogenerated methods
  //CHECKSTYLE:OperatorWrap:OFF
  @Override public String toString() {
    return "RuntimeTestResultSummaryImpl{" +
      "rollupTestResultEntry=" + rollupTestResultEntry +
      ", runtimeTestResultEntries=" + runtimeTestResultEntries +
      '}';
  }
  //CHECKSTYLE:OperatorWrap:OFF
}
